package com.elder.web.controller.business;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.elder.common.annotation.Anonymous;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.elder.common.annotation.Log;
import com.elder.common.core.controller.BaseController;
import com.elder.common.core.domain.AjaxResult;
import com.elder.common.enums.BusinessType;
import com.elder.business.domain.NurseContent;
import com.elder.business.service.INurseContentService;
import com.elder.common.utils.poi.ExcelUtil;
import com.elder.common.core.page.TableDataInfo;

/**
 * 护理内容Controller
 * 
 * @author zyk
 * @date 2023-11-26
 */
@RestController
@RequestMapping("/business/nurseContent")
public class NurseContentController extends BaseController
{
    @Autowired
    private INurseContentService nurseContentService;

    /**
     * 查询护理内容列表
     */
    @Anonymous
    @GetMapping("/list")
    public TableDataInfo list(String nurseName,Integer pageNum,Integer pageSize,String nurseStatus)
    {
        return nurseContentService.selectNurseContentList(nurseName,pageNum,pageSize,nurseStatus);
    }

    /**
     * 导出护理内容列表
     */
//    @Anonymous
//    @Log(title = "护理内容", businessType = BusinessType.EXPORT)
//    @PostMapping("/export")
//    public void export(HttpServletResponse response, NurseContent nurseContent)
//    {
//        List<NurseContent> list = nurseContentService.selectNurseContentList(nurseContent);
//        ExcelUtil<NurseContent> util = new ExcelUtil<NurseContent>(NurseContent.class);
//        util.exportExcel(response, list, "护理内容数据");
//    }

    /**
     * 获取护理内容详细信息
     */
    @Anonymous
    @GetMapping(value = "/{nurseId}")
    public AjaxResult getInfo(@PathVariable("nurseId") Long nurseId)
    {
        return success(nurseContentService.selectNurseContentByNurseId(nurseId));
    }

    /**
     * 新增护理内容
     */
    @Anonymous
    @Log(title = "护理内容", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody NurseContent nurseContent)
    {
        return toAjax(nurseContentService.insertNurseContent(nurseContent));
    }

    /**
     * 修改护理内容
     */
    @Anonymous
    @Log(title = "护理内容", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody NurseContent nurseContent)
    {
        return toAjax(nurseContentService.updateNurseContent(nurseContent));
    }

    /**
     * 删除护理内容
     */
    @Anonymous
    @Log(title = "护理内容", businessType = BusinessType.DELETE)
	@DeleteMapping("/{nurseIds}")
    public AjaxResult remove(@PathVariable Long[] nurseIds)
    {
        return toAjax(nurseContentService.deleteNurseContentByNurseIds(nurseIds));
    }

    @Anonymous
    @RequestMapping("/approval")
    public AjaxResult approval(Long nurseId ,String notes,String nurseStatus)
    {
        return nurseContentService.nurseContentApproval(nurseId,notes,nurseStatus);
    }
}
